package gui;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ListModel;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class MyJFrame extends javax.swing.JFrame {

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	private JMenuBar jMenuBar1;
	private JLabel jLabel3;
	private JLabel jLabel4;
	private JLabel jLabel5;
	private JTextArea jTextArea3;
	private JComboBox jComboBox2;
	private JButton jButton5;
	private JButton jButton4;
	private JTextField jTextField2;
	private JButton jButton2;
	private JComboBox jComboBox1;
	private JLabel jLabel2;
	private JButton jButton1;
	private JTextArea jTextArea2;
	private JLabel jLabel1;
	private JTextArea jTextArea1;
	private JMenuItem jMenuItem2;
	private JMenuItem jMenuItem1;
	private JMenu jMenu1;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				MyJFrame inst = new MyJFrame();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public MyJFrame() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			GridBagLayout thisLayout = new GridBagLayout();
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			thisLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1};
			thisLayout.rowHeights = new int[] {7, 7, 7, 7, 7};
			thisLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1};
			thisLayout.columnWidths = new int[] {7, 7, 7, 7, 7};
			getContentPane().setLayout(thisLayout);
			{
				jTextArea1 = new JTextArea();
				getContentPane().add(jTextArea1, new GridBagConstraints(1, 3, 2, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
				jTextArea1.setText("jTextArea1");
			}
			{
				ComboBoxModel jComboBox1Model = 
						new DefaultComboBoxModel(
								new String[] { "Item One", "Item Two" });
				jComboBox1 = new JComboBox();
				getContentPane().add(jComboBox1, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 13), 0, 0));
				jComboBox1.setModel(jComboBox1Model);
			}
			{
				jLabel1 = new JLabel();
				getContentPane().add(jLabel1, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 4, 2, 18), 0, 0));
				jLabel1.setText("La mémoire de travail :");
			}
			{
				jLabel2 = new JLabel();
				getContentPane().add(jLabel2, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
				jLabel2.setText("Question Proposée: ");
			}
			{
				jTextArea2 = new JTextArea();
				getContentPane().add(jTextArea2, new GridBagConstraints(0, 0, 1, 4, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(20, 0, 0, 20), 0, 0));
				//jTextArea2.setText("jTextArea2");
			}
			{
				jButton1 = new JButton();
				getContentPane().add(jButton1, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
				jButton1.setText("Ajouter");
				jButton1.addActionListener(new ActionListener() {

					@Override
					public void actionPerformed(ActionEvent arg0) {
					// TODO Auto-generated method stub
					try {
						System.out.println(jComboBox1.getSelectedItem().toString());
						jTextArea3.append(jComboBox1.getSelectedItem().toString()+"\n");
				       	//doBtSaveMap(arg0);
					} catch (Exception e) {
					      // TODO Auto-generated catch block
							e.printStackTrace();
					}
					}
					});
			}
			{
				jButton2 = new JButton();
				getContentPane().add(jButton2, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
				jButton2.setText("RUN");
			}
			{
				jTextField2 = new JTextField();
				getContentPane().add(jTextField2, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 15), 0, 0));
				jTextField2.setText("jTextField2");
			}
			{
				jLabel3 = new JLabel();
				getContentPane().add(jLabel3, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
				jLabel3.setText("Question pertinente :");
			}
			{
				jButton4 = new JButton();
				getContentPane().add(jButton4, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
				jButton4.setText("Vrai");
			}
			{
				jButton5 = new JButton();
				getContentPane().add(jButton5, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
				jButton5.setText("Faux");
			}
			{
				ComboBoxModel jComboBox2Model = 
						new DefaultComboBoxModel(
								new String[] { "Item One", "Item Two" });
				jComboBox2 = new JComboBox();
				getContentPane().add(jComboBox2, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 13), 0, 0));
				jComboBox2.setModel(jComboBox2Model);
			}
			{
				jLabel4 = new JLabel();
				getContentPane().add(jLabel4, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
				jLabel4.setText("Liste de règles  : ");
			}
			{
				jTextArea3 = new JTextArea();
				getContentPane().add(jTextArea3, new GridBagConstraints(4, 1, 1, 3, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 12, 0, 1), 0, 0));
				//jTextArea3.setText("jTextArea3");
			}
			{
				jLabel5 = new JLabel();
				getContentPane().add(jLabel5, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
				jLabel5.setText("Liste mémoire de base");
			}
			{
				jMenuBar1 = new JMenuBar();
				setJMenuBar(jMenuBar1);
				{
					jMenu1 = new JMenu();
					jMenuBar1.add(jMenu1);
					jMenu1.setText("Choice");
					{
						jMenuItem1 = new JMenuItem();
						jMenu1.add(jMenuItem1);
						jMenuItem1.setText("Load File");
						jMenuItem1.addActionListener(new ActionListener() {

							@Override
							public void actionPerformed(ActionEvent arg0) {
							// TODO Auto-generated method stub
							try {
								JFileChooser file = new JFileChooser();
								int retour = file.showOpenDialog(null);
								if(retour==JFileChooser.APPROVE_OPTION){
								   // un fichier a été choisi (sortie par OK)
								   // nom du fichier  choisi 
								   file.getSelectedFile().getName();
								  // System.out.println(file.getSelectedFile().toString());
								   BufferedReader file_in = new BufferedReader(
								            new FileReader(file.getSelectedFile().getPath()));
								   String ligne;
								   while ((ligne = file_in.readLine()) != null) {
									   System.out.println(ligne);
									   jTextArea2.append(ligne+"\n");
								   }
								   // chemin absolu du fichier choisi
								   file.getSelectedFile().
								          getAbsolutePath();
								}
							} catch (Exception e) {
							      // TODO Auto-generated catch block
									e.printStackTrace();
							}
							}
							});
					}
					{
						jMenuItem2 = new JMenuItem();
						jMenu1.add(jMenuItem2);
						jMenuItem2.setText("About this");
					}
				}
			}
			pack();
			this.setSize(804, 437);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
